package com.sen.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sen.entity.DruginfoEntity;
import com.sen.entity.SellheadEntity;
import com.sen.service.SellheadService;
import com.sen.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 销售信息表头表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2021-01-08 17:54:40
 */
@RestController
@RequestMapping("sellhead")
public class SellheadController {
    @Autowired
    private SellheadService sellheadService;

    /**
     * 查询所有销售订单
     * @param sellheadMap
     * @return
     */
    @RequestMapping("/queryAll")
    public R queryAll(@RequestParam Map<String,String> sellheadMap) {
//        List<SellheadEntity> sellHeads = sellheadService.queryAll(sellheadMap);
        Page<SellheadEntity> page = new Page<>(Integer.parseInt(sellheadMap.get("current")), Integer.parseInt(sellheadMap.get("size")));
        IPage<SellheadEntity> sellHeads = sellheadService.queryAll(page, sellheadMap);
        return R.ok().put("sellHeads", sellHeads);
    }

    /**
     * 图表数据
     * @param begin 开始时间
     * @param end 结束时间
     * @return
     */
    @GetMapping("/getDataSta/{begin}/{end}")
    public R getDataSta(@PathVariable String begin, @PathVariable String end){
        Map<String,Object> map = sellheadService.getDataSta(begin,end);

        return R.ok().put("staMap",map);
    }
}
